<template>
  <div>
    <el-dialog title="评论" :visible.sync="showComment">
      <el-table :data="comments">
        <el-table-column
          type="index"
          width="55">
        </el-table-column>
        <el-table-column
          label="用户"
          prop="name">
          <template slot-scope="scope">
            <img :src="scope.row.avatar" alt="" width="40">
            <span>{{ scope.row.name }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="内容"
          prop="content">
        </el-table-column>
        <el-table-column
          label="时间"
          prop="createtime">
        </el-table-column>
        <el-table-column
          label="点赞量"
          prop="fabulous">
        </el-table-column>
      </el-table>
      <div>
        <el-pagination
          background
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="page.pageNum"
          :page-sizes="[10, 15, 20, 25]"
          :page-size="page.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="page.total">
        </el-pagination>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'comment',
  data () {
    return {
      showComment: false,
      comments: [],
      params: {
        parid: '',
        type: ''
      },
      page: {
        pageNum: 1,
        pageSize: 20,
        total: 0
      }
    }
  },
  methods: {
    getList (p) {
      if (p) {
        Object.keys(this.params).forEach(key => {
          this.params[key] = p[key]
        })
      }
      let params = {...(this.params), page: this.page.pageNum, size: this.page.pageSize}
      this.axios.get('/Comment/getcomment', {params})
        .then(res => {
          if (res.data.status) {
            this.page.total = Number(res.data.data.count)
            this.comments = res.data.data.list
            this.showComment = true
          }
        })
    },
    handleSizeChange (e) {
      this.page.pageSize = e
      this.getList()
    },
    handleCurrentChange (e) {
      this.page.pageNum = e
      this.getList()
    }
  },
  created () {
  }
}
</script>

<style scoped>

</style>
